import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yt_devops/configs.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/services/task/task_services.dart';
import 'package:yt_devops/utils/func_utils.dart';

class FinishReportTaskController extends GetxController {
  TextEditingController textEditingController = TextEditingController();

  String description = '';

  TaskServices services = TaskServices();

  int? taskId;

  @override
  void onInit() {
    if (Get.arguments != null) {
      taskId = Get.arguments['id'];
    }
    super.onInit();
  }

  @override
  void onReady() {}

  @override
  void onClose() {}

  commit() => Configs.httpClient.requestWithLoading(() async {
        await services.finishReportTask(
            {"id": taskId, "description": textEditingController.text});

        FuncUtils.requestTipsDislog(
            Get.context, ResKey.submitSuccessTip.tr, true,
            duration: const Duration(seconds: 2));
        Future.delayed(const Duration(milliseconds: 2500), () {
          Get.back(result: true);
        });
      });
  void onChangehandle(String title) {
    description = title;
    update();
  }
}
